SPB Git forge

spb/toveli

Public
14commits 1branches 0releases
1.1 MBsize
maindefault branch
4 h agolast push
TypeScript 50.6% JavaScript 46.1% SQL 2.1% Shell 0.6% CSS 0.5%
1.5 KB · 18 lines tsx
Raw Blame History
1"use client";2import { useFavorites, useCompare } from "@/lib/favorites";3import { IconHeart, IconCompare, IconShare } from "@/components/icons";4import Link from "next/link";5export function ListingActions({ uid, url }: { uid: string; url: string | null; connector: string }) {6  const fav = useFavorites(); const cmp = useCompare();7  const share = async () => { const u = window.location.href; if (navigator.share) { try { await navigator.share({ url: u, title: document.title }); } catch { /* annulé */ } } else { await navigator.clipboard.writeText(u); alert("Lien copié"); } };8  return (9    <div className="mt-4 flex flex-wrap gap-2">10      <button type="button" onClick={() => fav.toggle(uid)} className={`tv-btn ${fav.has(uid) ? "tv-btn-primary" : "tv-btn-ghost"}`} aria-pressed={fav.has(uid)}><IconHeart width={16} height={16} filled={fav.has(uid)} /> {fav.has(uid) ? "Dans mes favoris" : "Favori"}</button>11      <button type="button" onClick={() => cmp.toggle(uid)} className="tv-btn tv-btn-ghost" aria-pressed={cmp.has(uid)}><IconCompare width={16} height={16} /> {cmp.has(uid) ? "Retirer du comparateur" : "Comparer"}</button>12      {cmp.items.length >= 2 && <Link href="/comparer" className="tv-btn tv-btn-ghost">Voir le comparateur ({cmp.items.length})</Link>}13      <button type="button" onClick={share} className="tv-btn tv-btn-ghost"><IconShare width={16} height={16} /> Partager</button>14      {url && <a href={url} target="_blank" rel="noopener nofollow" className="tv-btn tv-btn-ghost md:hidden">Annonce d'origine</a>}15    </div>16  );17}18